import store from '@/store/index'
import * as mutationsTypes from '@/store/mutations-types'

//登录注册的路由
export default [
  {
    path: '/createOrder',
    name: 'createOrder',
    component: () => import('@/views/order/create_order/CreateOrder'),
    children: [
      {
        path: 'chooseSeat',
        name: 'chooseSeat',
        component: () => import('@/views/order/choose_seat/ChooseSeat'),
      },
      {
        path: 'orderPay',
        name: 'orderPay',
        component: () => import('@/views/order/order_pay/OrderPay'),
      },
    ]
  },
  {
    path: '/ensurePay',
    name: 'ensurePay',
    component: () => import('@/views/order/ensure_pay/EnsurePay'),
  },
  {
    path: '/order',
    name: 'order',
    component: () => import('@/views/order/Order'),
    children: [
      {
        path: 'meOrder',
        name: 'meOrder',
        component: () => import('@/views/order/me_order/MeOrder'),
        beforeEnter: (to, from, next) => {
          console.log('从哪儿来: ' + from.path)
          console.log('到哪儿去: ' + to.path)
          if (store.getters.getUser.userId === 0) {
            next('/')
          } else {
            next()
          }
        }
      },
      {
        path: 'basicInfo',
        name: 'basicInfo',
        component: () => import('@/views/order/basic_info/BasicInfo'),
      },
    ]
  },
]